<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>工程评价</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    {CSS href="__ADDONSTATIC__css/font.css" /}
    {CSS href="__ADDONSTATIC__css/xadmin.css" /}
    {js href='__ADDONSTATIC__js/jquery-3.2.1.min.js' /}

    {js href='__ADDONSTATIC__js/xadmin.js' /}
    {js href='__ADDONSTATIC__js/util.js' /}
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    {js href='__ADDONSTATIC__lib/layui/layui.js' /}
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .layui-table tr th {
            font-weight: bold;
        }
    </style>
</head>

<body>
<input type="hidden" id="projectId" value="{$project.id}">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-input">
            <select name="status" lay-filter="status">
                {if condition="!$project.statusId"}
                    <option value="" selected>请选择</option>
                {/if}
                {foreach name="status" item ="value"}
                {if condition="$project.statusId <= $value.id"}
                    {if condition="$project.statusId == $value.id"}
                    <option value="{$value.id}" selected>{$value.description}</option>
                    {else /}
                    <option value="{$value.id}">{$value.description}</option>
                    {/if}
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
</form>

<div style="position: absolute; left: 45%;bottom: 10%;">
    <button class="layui-btn" onclick="changeStatus({$project.id})">确定</button>
</div>
</body>
<script>

    var status = "{$project.statusId}";
    layui.use('form', function () {
        var form = layui.form;
        form.on('select(status)', function (data) {
            status = data.value;
        });
    });


    function changeStatus(projectId) {
        layer.confirm('确认变更状态？', function (index, layero) {
            layer.close(index);
            if(!status){
                layer.alert("选择错误！");
            }else{
                //发异步把用户状态进行更改
                ajaxUrl("{:addonUrl(Admin/changeStatus)}",
                        {projectId: projectId, status: status}, function (data) {
                            console.log(data);
                            if (data.code == 1) {
                                x_admin_close();
                            } else {
                                layer.alert("修改失败");
                            }
                        })
            }
        });
    }
</script>
</html>